home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 15
/
Aminet 15 - Nov 1996.iso
/
Aminet
/
text
/
dtp
/
txtRotator303.lha
/
txtRotator303.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1996-09-25
|
10KB
|
347 lines
/*--------------------------------------*/
/* $VER: txtRotator V3.03 (25 Sep 1996) */
/* ©1996 Michael Merkel */
/*--------------------------------------*/
/*
how to use this:
----------------
1. draw a circle/ellipse/arc/pie with PageStream3
(please use PageStream3.1 BETA 3 or higher with this script
due to problems with rotated text objects in earlier versions)
2. select this object
3. start this script
4. press OK to see what happens
notes:
------
* this script does NOT work with rotated objects!
(do it with the unrotated object first then group it and rotate all)
* it only works with "normal" circles/ellipses/arcs/pies
* text around ellipses sometimes look wierd - play with it
comments to this program to:
----------------------------
mmerkel@rummelplatz.uni-mannheim.de
this is my first public arexx-script... don't blame me for that :-)
IF YOU LIKE THIS SCRIPT PLEASE SEND ME A HARDCOPY OF THE
PAGESTREAM SCREEN WITH YOUR WORK ON IT!
happy rotating...
Michael Merkel
*/
OPTIONS RESULTS
/* Make sure rexx support is opened */
IF ~SHOW('L','rexxsupport.library') THEN
CALL ADDLIB('rexxsupport.library',0,-30)
IF ~SHOW('L','softlogik:libs/slarexxsupport.library') THEN
CALL ADDLIB('softlogik:libs/slarexxsupport.library',0,-30)
IF ~SHOW('L','rexxmathlib.library') THEN
CALL ADDLIB('rexxmathlib.library',0,-30)
ADDRESS 'PAGESTREAM'
'GETOBJECT TYPE 'typ
ret = RESULT
if (typ ~= 7) | (ret = 10) then call DOERRORREQUESTER
'getellipse position koordinaten angles winkel'
id = result
typ = winkel.type
startw = 0
endw = 360
if winkel.type ~= 'ELLIPSE' then do
endw = (450 - p2d(winkel.begin)) // 360
startw = (450 - p2d(winkel.end)) // 360
if endw < startw then endw = endw + 360
end
call ReadTXTRotatorPrefs
measure = 'pt'
posifaktor = 1
rifaktor = 1
mx = p2d(koordinaten.centerx,measure)
my = p2d(koordinaten.centery,measure)
rx = p2d(koordinaten.radiusx,measure)
ry = p2d(koordinaten.radiusy,measure)
call DOREQUESTER
if ergebnis = cancelhandler THEN EXIT
call WriteTXTRotatorPrefs
size = textsize
r = radius
mx = mx
my = my
rx = rx
ry = ry
/* ---------------------------------------------------------------- */
'REFRESH OFF'
'OPENBUSYREQUESTER MESSAGE "text is placed around 'typ'..." THERMOMETER ENABLED ABORT ENABLED TOTAL 'l' CURRENT 0'
BusyReq=result
highwinkel = -3.1415 * 0.5 + endw*3.1415/180
lowwinkel = -3.1415 * 0.5 + startw*3.1415/180
altrx = rx
altry = ry
deltaradiusx = rx - (rx*icf)
deltaradiusy = ry - (ry*icf)
deltaradiusrundx = deltaradiusx / xfaktor
deltaradiusrundy = deltaradiusy / xfaktor
deltabuchstaben = l / xfaktor
deltaminusx = deltaradiusrundx / deltabuchstaben
deltaminusy = deltaradiusrundy / deltabuchstaben
do num = 0 to l-1
call setbusy(num)
'DRAWTEXTOBJ 'mx''measure' 'my''measure' INFRONT'
textid = RESULT
'SELECTTEXT AT 'mx''measure' 'my''measure' FRONTMOST'
'SETTYPESIZE 'size
'SETPARAGRAPHSTYLE 'charstyle
'INSERT "'SUBSTR(text,num+1,1)'"'
'GETTEXTOBJ POSITION txtpos2 OBJECTID 'textid
if icf ~= 1 then call SCALEOBJECT(textid,(rx/altrx))
txtheight = p2d(txtpos2.bottom,measure) - p2d(txtpos2.top,measure)
txtwidth = p2d(txtpos2.right,measure) - p2d(txtpos2.left,measure)
sinus = (highwinkel-lowwinkel) / (l-1) * num + lowwinkel
dreh = sinus * 180 / 3.1415
sinusresult = sin(sinus)
cosinusresult = cos(sinus)
nrx = rx + (txtheight/2)*posifaktor
nry = ry + (txtheight/2)*posifaktor
xx2 = mx + cosinusresult * nrx
yy2 = my + sinusresult * nry
movx = (xx2-mx-(txtwidth/2))
movy = (yy2-my-(txtheight/2))
'MOVE OFFSET 'movx''measure' 'movy''measure' OBJECTID 'textid
/* Berechnen des Buchstaben-Drehwinkels */
x0 = cosinusresult * rx
y0 = sinusresult * ry
if y0 = 0 then
dreh = -3.1415 / 2
else do
dreh = (x0*ry*ry)/(y0*rx*rx)
dreh = atan(dreh)
end
dreh = 180 + dreh * 180 / 3.1415
if (y0 * rifaktor) > 0 then
'ROTATE 'dreh'°'
else
'ROTATE '180+dreh'°'
if SUBSTR(text,num+1,1)==' ' then 'DELETEOBJECT objectid 'textid
rx = rx - deltaminusx
ry = ry - deltaminusy
end
call CLEANUP(1)
DOREQUESTER:
'ALLOCAREXXREQUESTER "text around 'typ' V3.02 ©1996 Michael Merkel" 320 200'
reqhandle = RESULT
'ADDAREXXGADGET 'reqhandle' EXIT 10 180 70 LABEL "_Ok"'
okhandler = RESULT
'ADDAREXXGADGET 'reqhandle' EXIT 240 180 70 LABEL "_Cancel"'
cancelhandler = RESULT
'ADDAREXXGADGET 'reqhandle' STRING 150 10 50 STRING "'startw'" LABEL "angles (°) start:"'
start_gadget = RESULT
'ADDAREXXGADGET 'reqhandle' STRING 250 10 50 STRING "'endw'" LABEL "end:"'
end_gadget = RESULT
'ADDAREXXGADGET 'reqhandle' STRING 86 30 50 STRING "'textsize'" LABEL "fontsize:"'
s_gadget = RESULT
'ADDAREXXGADGET 'reqhandle' STRING 200 30 115 STRING "'charstyle'" LABEL "style:"'
style_gadget = RESULT
'ADDAREXXGADGET 'reqhandle' STRING 10 60 305 STRING "'text'" LABEL "text to be placed:" LABELPOS "ABOVELEFT"'
t_gadget = RESULT
'ALLOCAREXXLIST'
rexxlist = RESULT
'ADDAREXXLIST 'rexxlist' "above line"'
'ADDAREXXLIST 'rexxlist' "below line"'
'ADDAREXXLIST 'rexxlist' "on line"'
'ADDAREXXGADGET 'reqhandle' CYCLE 94 90 120 LABEL "place text"'
c_gadget = RESULT
'SETAREXXGADGET 'reqhandle' 'c_gadget' LIST 'rexxlist' CURRENT 'tposi
'ALLOCAREXXLIST'
rexxlist2 = RESULT
'ADDAREXXLIST 'rexxlist2' "clockwise"'
'ADDAREXXLIST 'rexxlist2' "counterclockwise"'
'ADDAREXXGADGET 'reqhandle' CYCLE 46 110 168 LABEL "text"'
ri_gadget = RESULT
'SETAREXXGADGET 'reqhandle' 'ri_gadget' LIST 'rexxlist2' CURRENT 'richtung
'ADDAREXXGADGET 'reqhandle' STRING 174 130 40 STRING "'icf'" LABEL "inner circle factor:"'
icf_gadget = RESULT
'ADDAREXXGADGET 'reqhandle' STRING 126 145 40 STRING "'xfaktor'" LABEL "surrounding #:"'
xfaktor_gadget = RESULT
'DOAREXXREQUESTER 'reqhandle
ergebnis = RESULT
'GETAREXXGADGET 'reqhandle' 'start_gadget' STRING'
startw = RESULT
'GETAREXXGADGET 'reqhandle' 'end_gadget' STRING'
endw = RESULT
'GETAREXXGADGET 'reqhandle' 's_gadget' STRING'
textsize = RESULT
'GETAREXXGADGET 'reqhandle' 'style_gadget' STRING'
charstyle = RESULT
'GETAREXXGADGET 'reqhandle' 't_gadget' STRING'
text = RESULT
l = length(text)
'GETAREXXGADGET 'reqhandle' 'c_gadget' CURRENT'
tposi = RESULT
'GETAREXXGADGET 'reqhandle' 'ri_gadget' CURRENT'
richtung = RESULT
'GETAREXXGADGET 'reqhandle' 'icf_gadget' STRING'
icf = RESULT
'GETAREXXGADGET 'reqhandle' 'xfaktor_gadget' STRING'
xfaktor = RESULT
if tposi=1 then posifaktor = -1
if tposi=2 then posifaktor = 0
endw = endw + 360*(xfaktor-1)
if richtung = 1 then do
rifaktor = -1
dummy = startw
startw = endw
endw = dummy
end
'FREEAREXXREQUESTER 'reqhandle
'FREAREXXLIST 'rexxlist
'FREAREXXLIST 'rexxlist2
RETURN
DOERRORREQUESTER:
say 'Error: No circle/ellipse/arc/pie selected!'
'ALLOCAREXXREQUESTER "Error!" 400 70'
reqhandle = RESULT
'ADDAREXXGADGET 'reqhandle' EXIT 165 50 70 LABEL "_Ok"'
dummy = RESULT
'ADDAREXXGADGET 'reqhandle' TEXT 10 10 390 STRING "You did not chose an arc/ellipse/circle/pie!"'
'ADDAREXXGADGET 'reqhandle' TEXT 10 30 390 STRING "Select one and start me again!"'
'DOAREXXREQUESTER 'reqhandle
dummy = RESULT
'FREEAREXXREQUESTER 'reqhandle
exit
RETURN
SCALEOBJECT:
parse arg objectidnew,factor
txt_x = p2d(txtpos2.left,measure)
txt_y = p2d(txtpos2.top,measure)
txt_xx = p2d(txtpos2.right,measure)
txt_yy = p2d(txtpos2.bottom,measure)
txtheight = txt_yy - txt_y
txtwidth = txt_xx - txt_x
newtxt_x = txt_x + txtwidth * factor
newtxt_y = txt_y + txtheight * factor
'EDITTEXTOBJ POSITION 'txt_x''measure' 'txt_y''measure' 'newtxt_x''measure' 'newtxt_y''measure' OBJECTID 'objectidnew
'GETTEXTOBJ POSITION txtpos2 OBJECTID 'textid
RETURN
SETBUSY:
parse arg value
'SETBUSYREQUESTER 'BusyReq' CURRENT 'value
'GETBUSYREQUESTER 'BusyReq
if result=1 then call CLEANUP(1)
RETURN
CLEANUP:
'CLOSEBUSYREQUESTER 'BusyReq
'REFRESH ON'
'REFRESHWINDOW'
EXIT
ReadTXTRotatorPrefs:
ok = Open('Prefs','PageStream3:Scripts/txtRotator.prefs','R')
if ok = 1 then do
say 'reading old prefs...'
textsize = ReadLN('Prefs')
charstyle = ReadLN('Prefs')
text = ReadLN('Prefs')
tposi = ReadLN('Prefs')
richtung = ReadLN('Prefs')
icf = ReadLN('Prefs')
xfaktor = ReadLN('Prefs')
Close('Prefs')
end
else do
say 'unable to read prefs -> default values'
textsize = '20pt'
charstyle = 'RoundText'
text = 'abcdefghijklmnopqrstuvwxyz0123456789 '
tposi = 0
richtung = 0
icf = 1
xfaktor = 1
end
RETURN
WriteTXTRotatorPrefs:
ok = Open('Prefs','PageStream3:Scripts/txtRotator.prefs','W')
if ok = 1 then do
say 'writing prefs...'
WriteLN('Prefs',textsize)
WriteLN('Prefs',charstyle)
WriteLN('Prefs',text)
WriteLN('Prefs',tposi)
WriteLN('Prefs',richtung)
WriteLN('Prefs',icf)
WriteLN('Prefs',xfaktor)
Close('Prefs')
end
else do
say 'error writing prefs file "txtRotator.prefs"'
end
RETURN